package com.hfy.user.controller;

import com.alibaba.fastjson.JSON;
import com.hfy.model.dto.RegisterDto;
import com.hfy.user.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import result.Result;

/**
 * @ author 韩
 * time: 2024/5/10 2:02
 */
@RestController
public class RegisterController {

    @Autowired
    private RegisterService registerService;

    @PostMapping("/register")

    // todo 需要修改
    public Result register(@RequestParam("avatar") MultipartFile avatar,@RequestParam("jsonData") String jsonDataStr) {
        RegisterDto dto = JSON.parseObject(jsonDataStr, RegisterDto.class);
        return registerService.register(avatar,dto.getUsername(),dto.getPassword());
    }


}
